package com.zuoye.day04;


//信用账户
public class CreditAccount extends Account {
    public float maxOverdraft;
    public String credit;
    public float alreadyOverdraft;  //已透支额度



    public CreditAccount(){

    }


    //取钱
    public float  withdraw(float balance){
        if(accBalance > balance){
            accBalance -= balance;
            return accBalance;
        }
        if (accBalance < balance && maxOverdraft > balance) {
            maxOverdraft -= balance;
            return maxOverdraft;
        }
        if (accBalance < balance && maxOverdraft < balance){
            alreadyOverdraft = balance - maxOverdraft;
            return alreadyOverdraft;
        }
        return alreadyOverdraft;
    }




    public float getMaxOverdraft() {
        return maxOverdraft;
    }

    public void setMaxOverdraft(float maxOverdraft) {
        this.maxOverdraft = maxOverdraft;
    }

    public String getCredit() {
        return credit;
    }

    public void setCredit(String credit) {
        this.credit = credit;
    }
    public float getAlreadyOverdraft() {
        return alreadyOverdraft;
    }

    public void setAlreadyOverdraft(float alreadyOverdraft) {
        this.alreadyOverdraft = alreadyOverdraft;
    }
}
